<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>{:session('cp.cpsysname')}--服务商管理平台</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="description" content="{:config('webconfig.description');}">
    <meta name="keywords" content="{:config('webconfig.keywords');}">
    <meta name="author" content="runoob">
    <link rel="stylesheet" href="__STATIC_URL__/static/bootstrap/3.3.7/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="__STATIC_URL__/static/css/index.css"/>
    <script src="__STATIC_URL__/static/jquery/2.2.1/jquery.min.js"></script>
    <script src="__STATIC_URL__/static/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script src="__STATIC_URL__/static/layer/layer.js"></script>
</head>
<style>
    .img-responsive {
        display: block;
        max-width: 100% !important;
        height: auto !important;
    }
    .adminex-form .col-sm-9{
        padding-right: 30px;
        padding-left: 0;
    }
    #tk-tbody td{
        line-height: 32px;
    }
</style>
<body>
{include file='public/header'/}
<section>
    <!------------------导航-------------------------->
    {include file='public/left'/}
    <!--------------------------主要内容区域------------------------------------->
    <div class="content">
        <div class="page-heading mgl15 mgr15">
            <ul class="breadcrumb">
                <li>当前位置是:</li>
                <li><a href="{:url('momach/momachlist')}">商户管理</a></li>
                <li><a href="javascript:history.back();">门店列表</a></li>
                <li class="active" style="color: #02b87f;">门店详情</li>
            </ul>
        </div>
        <div class="mgl15 mgr15">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h4 style="margin:0;font-size:16px;color:#02b87f;">门店名称&nbsp;:&nbsp;<span>{$user.merchant}</span>
                    </h4>
                </div>
            </div>
            <ul id="myTab" class="nav nav-tabs mgb10">
                <li>
                    <a class="fsz14" href="#Message" data-toggle="tab">基础信息</a>
                </li>
                <li>
                    <a class="fsz14" href="#Facility" data-toggle="tab">查看设备码</a>
                </li>
            </ul>
            <div id="myTabContent" class="tab-content">
                <div class="tab-pane fade" id="Message">

                    <table class="table table-bordered">
                        <caption>基础信息</caption>
                        <tbody>
                        <tr>
                            <td class="active">营业状态</td>
                            <td>{:getmachstatu($user['status'])}</td>
                            <td class="active">创建时间</td>
                            <td>{$user['addtime']|date="Y-m-d H:i:s",###}</td>
                            <td class="active">门店类别</td>
                            <td>{:getlevel($user['leibie'])}</td>
                        </tr>
                        </tbody>
                    </table>
                    <table class="table table-bordered">
                        <caption>代理商信息</caption>
                        <tbody>
                        <tr>
                            <td class="active">业务员</td>
                            <td>{:getsales($user['salesman'])}</td>
                            <td class="active">代理商名称</td>
                            <td colspan="3">{:getagent($user['agent'],"name")}</td>
                        </tr>
                        </tbody>
                    </table>
                    <table class="table table-bordered">
                        <caption>商户信息</caption>
                        <tbody>
                        <tr>
                            <td class="active">微信商户号</td>
                            <td colspan="2">{$user['sub_mch_id']}</td>
                            <td class="active">支付宝Token</td>
                            <td colspan="2">{$user['ali_merid']}</td>
                        </tr>
                        <tr>
                            <td class="active">商户联系人</td>
                            <td>{$user['MerchantContent']['contacts']}</td>
                            <td class="active">联系方式</td>
                            <td>{$user['MerchantContent']['tel']}</td>
                            <td class="active">地址</td>
                            <td>{$user['MerchantContent']['address']}</td>
                        </tr>
                        </tbody>
                    </table>

                    <table class="table table-bordered">
                        <caption>微信公众号授权</caption>
                        <tbody>
                        <tr>

                            <td class="active">授权情况</td>
                            <td>{if condition="$user['auth_type'] eq 0"}继承上级商户公众号{else /}自有公众号{/if}：<font color="green"> {$wxopen['gh_nick_name']}</font></td>

                            <td class="active">Appid</td>
                            <td>{$wxopen['authorizer_appid']}</td>

                            <td class="active">原始ID</td>
                            <td>{$wxopen['gh_id']}</td>
                        </tr>
                        <tr>
                            <td class="active">公众号认证信息</td>
                            <td>{:getwxlx($wxopen['verify_type_info'])}{:getwxrz($wxopen['service_type_info'])}</td>
                            <td class="active">认证主体</td>
                            <td>{$wxopen['principal_name']}</td>
                            <td class="active">授权时间</td>
                            <td>{:date('Y-m-d H:i:s',$wxopen['addtime'])}</td>

                        </tr>
                        </tbody>
                    </table>
              
                </div>
                <!--设备列表-->
                <div class="tab-pane fade" id="Facility">
                    {if condition="checkPath('momach/add_device_micro')"}
                    <div class="col-sm-12 text-right mgb10">
                        <button data-toggle="modal" data-target="#myModal2" type="button" name="Facility" method="post" action="" class="btn btn-info">生成设备码
                        </button>
                    </div>
                    {/if}
                    <table class="table table-bordered">
                        <thead>
                        <tr class="active">
                            <th>设备名称</th>
                            <th>状态</th>
                            <th>绑定码</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody id="tk-tbody">
                        {volist name="devicelist" id="vo"}
                        <tr>
                            <td>{$vo.device_name}</td>
                            <td>
                                {if condition="$vo['status'] eq '1' "}
                                <a href="javascript:;" class="xgbang btn-link" data-id="{$vo.id}" data-toggle="modal" data-target="#xgbangding">修改</a>
                                <a href="javascript:;" class="delbang btn-link" data-id="{$vo.id}">解绑</a>
                                {else/}
                                未绑定
                                {/if}
                            </td>
                            <td><input type="text" class="form-control"  readonly  value="{$vo.code}"></td>
                            <td><a href="javascript:;" class="btn-link delcode" data-id="{$vo.id}">删除</a></td>
                        </tr>
                        {/volist}
                        </tbody>
                    </table>
                    {$devicelist->render()}
                </div>
            </div>
        </div>
        {include file='public/footer'/}
    </div>
</section>
<!-- 添加设备模态框（Modal） -->
<div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    生成设备码
                </h4>
            </div>
            <div class="modal-body">
                <div id="myTabContent2" class="tab-content" style="margin-top: 15px;">
                    <div class="tab-pane fade in active" id="print">
                        <form class="form-horizontal" id="bangdingform">
                            <div class="form-group">
                                <label class="col-sm-3 control-label">设备名称：</label>
                                <div class="col-sm-9">
                                    <input type="text" class="form-control" oninput="value=value.replace(/[^\w\.\/]/ig,'')" maxlength="8" name="device_name" placeholder="请输入设备名称"/>
                                    <div class="r-desc ng-binding ng-scope">设备名称只能输入英文和数字，最多8个字符</div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">退款密码：</label>
                                <div class="col-sm-9">
                                    <input type="hidden" id="scbdm" name="mid" value="{:request()->get('id')}"/>
                                    <input type="hidden" id="is_tk" name="is_tk" value="1"/>
                                    <input type="text" class="form-control" name="tk_pass" placeholder="请输入密码"/>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" id="bingsure">生成</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>
<!-- 修改绑定退款密码Modal 开始-->
<div class="modal fade" id="xgbangding" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="xgbangdingLabel">绑定收银设备</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" id="xgbangdingform">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">退款密码：</label>
                        <div class="col-sm-9">
                            <input type="hidden" id="tkid" name="id"/>
                            <input type="text" name="tk_pass" class="form-control" placeholder="请输入密码"/>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" id="xgbingsure">完成</button>
            </div>
        </div>
    </div>
</div>

</body>
<script type="text/javascript">
    $(function(){
        var id = "{:request()->get('id')}";
        var currentTab = "{:request()->get('type')}";
        if(!currentTab){
            $('#myTab a[href="#Message"]').tab('show')
        }else{
            if(currentTab==1){
                $('#myTab a[href="#Message"]').tab('show')
            }else{
                $('#myTab a[href="#Facility"]').tab('show')
            }
        }
        var reloadUrl = "{:url('momach/machinfo')}?id="+id+"&type=1";
        var reloadUrl1 ="{:url('momach/machinfo')}?id="+id+"&type=2";
        $('#myTab a[href="#Message"]').click(function (e) {
            e.preventDefault()
            window.location.href=reloadUrl;
        });
        $('#myTab a[href="#Facility"]').click(function (e) {
            e.preventDefault()
            window.location.href=reloadUrl1;
        });
//        生成绑定码
        $("#bingsure").click(function(){
            $(this).attr("disabled","disabled");
            $.ajax({
                url:"{:url('momach/add_device_micro')}",
                type:"post",
                data:$("#bangdingform").serialize(),
                success:function(data){
                    if(data.code==0){
                        $("#myModal2").modal("hide");
                        $("#bingsure").removeAttr("disabled");
                        layer.msg(data.message,{icon:1});
                        setTimeout("window.location.reload()",1000)
                        return false;
                    }else{
                        layer.alert(data.message);
                        return false;
                    }
                }
            })
        });
        //        修改绑定密码 开始
        $("#xgbangding").on('show.bs.modal', function () {
            //                    判断是否有权限修改密码
            var qx = "{:checkPath('momach/device_micro_md_pass')}";
            if(qx==0){
                layer.alert("您没有权限进行修改",{icon:7});
                return false;
            }
            var mid = $(event.target).data("id");
            $("#tkid").val(mid);
        });
        $("#xgbingsure").click(function(){
            $("this").attr("disabled","disabled");
            $.ajax({
                url:"{:url('momach/device_micro_md_pass')}",
                type:"post",
                data:$("#xgbangdingform").serialize(),
                success:function(data){
                    if(data.code==0){
                        layer.msg(data.message,{icon:1});
                        setTimeout("window.location.reload()",1000)
                        return false;
                    }else{
                        layer.alert(data.message);
                        return false;
                    }
                }
            })
        });
//        修改绑定密码 结束
        //        解绑绑定密码 开始
        $("#tk-tbody").on("click",".delbang",function(){
            //                    判断是否有权限修改密码
            var qx = "{:checkPath('momach/device_mirco_jb')}";
            if(qx==0){
                layer.alert("您没有权限进行解绑",{icon:7});
                return false;
            }
            var id = $(this).attr("data-id");
            layer.confirm('正在进行解绑操作！', {
                btn: ['确认','取消'] //按钮
            }, function(){
                $.ajax({
                    url:"{:url('momach/device_mirco_jb')}",
                    type:"post",
                    data:{
                        id:id
                    },
                    success:function(data){
                        if(data.code==0){
                            layer.msg(data.message,{icon:1});
                            setTimeout("window.location.reload()",1000);
                            return false;
                        }else{
                            layer.alert(data.message);
                            return false;
                        }
                    }
                })
            }, function(){

            });

        });
//        解绑绑定密码 结束
        //        删除绑定吗 开始
        $("#tk-tbody").on("click",".delcode",function(){
            //                    判断是否有权限修改密码
            var qx = "{:checkPath('momach/del_device_mirco')}";
            if(qx==0){
                layer.alert("您没有权限进行删除",{icon:7});
                return false;
            }
            var id = $(this).attr("data-id");
            layer.confirm('正在进行删除操作！', {
                btn: ['确认','取消'] //按钮
            }, function(){
                $.ajax({
                    url:"{:url('momach/del_device_mirco')}",
                    type:"post",
                    data:{
                        id:id
                    },
                    success:function(data){
                        if(data.code==0){
                            layer.msg(data.message,{icon:1});
                            setTimeout("window.location.reload()",1000);
                            return false;
                        }else{
                            layer.alert(data.message);
                            return false;
                        }
                    }
                })
            }, function(){

            });

        });
//        删除绑定吗 结束
    })
</script>

</html>